package org.glorylight.hacks.social.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name = "tips")
@NamedQueries({
	@NamedQuery(name = "tips-by-age", query = "from Tips a where a.startAge <= :age and endAge>= :age")
})
public class Tips implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id
	private String id;
	
	@Column(name = "startAge", nullable = false)
	private Float startAge;
	
	@Column(name = "endAge", nullable = false)
	private Float endAge;
	
	@Column(name = "tags", length = 250)
	private String tags;
	
	@Column(name = "title", nullable = false, length = 50)
	private String title;
	
	@OneToOne(fetch = FetchType.LAZY, mappedBy = "tips", cascade = CascadeType.ALL)
	@PrimaryKeyJoinColumn
	private TipsDetail tipsDetail;
	
	public Tips() {
		
	}

	public Tips(String id, Float startAge, Float endAge, String tags, String title, TipsDetail tipsDetail) {
		this.id = id;
		this.startAge = startAge;
		this.endAge = endAge;
		this.tags = tags;
		this.title = title;
		this.tipsDetail = tipsDetail;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Float getStartAge() {
		return startAge;
	}

	public void setStartAge(Float startAge) {
		this.startAge = startAge;
	}

	public Float getEndAge() {
		return endAge;
	}

	public void setEndAge(Float endAge) {
		this.endAge = endAge;
	}

	public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public TipsDetail getTipsDetail() {
		return tipsDetail;
	}

	public void setTipsDetail(TipsDetail tipsDetail) {
		this.tipsDetail = tipsDetail;
	}
}
